import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import nodejs from '@dfeidao/atom-web/msg/nodejs';
import render from '@dfeidao/atom-web/render/render';
import set_node_cls from "@dfeidao/atom-web/ui/set-node-cls";
import p001 from './p001';
import p002 from './p002';
import p003 from './p003';

export default async function a004(fd: IFeidaoAiBrowserComponent) {
	// 查询行业领域名称

	const d = fd.data.node.querySelector<HTMLInputElement>('[data-name="name1"]');
	const v = d.value;

	const res = await nodejs<{ res: Array<{}>; c: number; }>('customer-care/zj-000003/s001', {
		industry_domain_name: v,
		page_no: 1
	});
	console.info(res);


	const p1 = fd.data.node.querySelector<HTMLDivElement>('[data-feidao-presentation="p001"]');
	const p2 = fd.data.node.querySelector<HTMLDivElement>('[data-feidao-presentation="p002"]');
	const p3 = fd.data.node.querySelector<HTMLDivElement>('[data-feidao-presentation="p003"]');
	if (res.res.length > 0) {
		render(fd, res.res, p001, 'p001', 'inner');
		render(fd, { page_no: 1, total: res.c }, p002, 'p002', 'inner');

		set_node_cls(p1, 'display-n', false);
		set_node_cls(p2, 'display-n', false);
		set_node_cls(p3, 'display-n', true);
	} else {
		render(fd, '', p003, 'p003', 'inner');

		set_node_cls(p1, 'display-n', true);
		set_node_cls(p2, 'display-n', true);
		set_node_cls(p3, 'display-n', false);
	}
}
